package com.battery.system.mapper;

import com.battery.system.base.BaseMapper;
import com.battery.system.domain.BO.IncomeBO;
import com.battery.system.domain.Income;
import com.battery.system.domain.IncomeTrend;
import com.battery.system.domain.VO.*;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 收益Mapper接口
 *
 * @author battery
 * @date 2021-01-22
 */
public interface IncomeMapper extends BaseMapper<Income> {
    /**
     * 查询收益
     *
     * @param id 收益ID
     * @return 收益
     */
    public Income selectIncomeById(String id);

    /**
     * 查询收益列表
     *
     * @param income 收益
     * @return 收益集合
     */
    public List<Income> selectIncomeList(Income income);

    /**
     * 新增收益
     *
     * @param income 收益
     * @return 结果
     */
    public int insertIncome(Income income);

    /**
     * 修改收益
     *
     * @param income 收益
     * @return 结果
     */
    public int updateIncome(Income income);

    /**
     * 删除收益
     *
     * @param id 收益ID
     * @return 结果
     */
    public int deleteIncomeById(String id);

    /**
     * 批量删除收益
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteIncomeByIds(String[] ids);

    BillDetails selectIncomeSum(@Param("map") Map<String, String> map);

    List<BillDetails> selectIncomeGroup(@Param("map") Map<String, String> map);

    IncomeCount selectIncomeByCount(@Param("map") Map<String, String> map);


    IncomeCount selectIncomeByCountDetails(@Param("id") String id, @Param("type") int type, @Param("toDay") int toDay,
                                           @Param("start") String start, @Param("end") String end);

    List<IncomeCount> selectIncomeByMyIncome(@Param("map") Map<String, String> map);


    PartnerCount selectPartnerByStoreCount(@Param("id") String id);


    List<StoreCount> selectPartnerByStoreGroup(@Param("map") Map<String, String> map);

    /**
     * 收益列表
     *
     * @param incomeBO
     * @return
     */
    List<IncomeVO> selectIncomeVOList(@Param("incomeBO") IncomeBO incomeBO);

    List<IncomeTrend> selectIncomeByTrendDay(@Param("map") Map<String, String> map);

    List<IncomeTrend> selectIncomeByTrendMonth(@Param("map") Map<String, String> map);

    List<IncomeTrend> selectIncomeByTrendWeek(@Param("map") Map<String, String> map);

    /**
     * 贡献收支明细 (门店贡献收支明细)
     *
     * @param map
     * @return
     */
    List<Income> incomeRecordByMap(@Param("map") Map<String, String> map);

    /**
     * 账单明细
     *
     * @param incomeBO
     * @return
     */
    List<IncomeVO> selectOnlyIncomeVOList(@Param("incomeBO") IncomeBO incomeBO);

    /**
     * 查询该账号在此租借订单，拿到的收益
     *
     * @param usedId
     * @param accountId
     * @param accountType
     * @return
     */
    BigDecimal selectAccountByUsedId(@Param("usedId") String usedId, @Param("accountId") String accountId, @Param("accountType") int accountType);

    /**
     * 查询商户的收益总和
     *
     * @param map
     * @return
     */
    BigDecimal merchantIncomeSumById(@Param("map") Map<String, String> map);
}

